﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="d" uri="/WEB-INF/resource.tld" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  
</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>
  
  <%@ include file="/WEB-INF/include/menu.jsp"%>
  
  <div class="container main-content">

    <div class="panel panel-default x-panel x-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/online-rounds">课程管理</a></li>
          <li class="active">课件管理</li>
          <li class="no-before pull-right" style="min-width: 65px;">
            <a onclick="window.history.back();"><i class="glyphicon glyphicon-arrow-left"></i>&nbsp;&nbsp;返回</a>
          </li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">

          <div class="x-breadcrumb-wrapper">
            <div class="x-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire" title="分组模板详情"></i>&nbsp;&nbsp;<span>分组管理&nbsp;-&nbsp;详情</span></h2>
            </div>
          </div>
          
          <div class="x-breadcrumb-wrapper top-margin-20" style="position: relative;">
            <ul class="nav nav-pills x-breadcrumb-nav">
                <li class="pull-left"><a href="${ctx.host}/fitness-groups/${fitnessGroup.id}">基本信息</a></li>
                <c:if test="${fitnessGroup.type.offline or fitnessGroup.type.online}">
                  <li class="pull-left ${type == 'weekly' ? 'active' : ''}"><a href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/1?type=weekly">${fitnessGroup.type.online ? '每周课件' : '家庭作业'}</a></li>
                </c:if>
                <c:if test="${fitnessGroup.type.offline}">
                  <li class="pull-left ${type == 'course' ? 'active' : ''}"><a href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/1?type=course&day=1">上课课件</a></li>
                </c:if>
                <c:if test="${fitnessGroup.type.specialty}">
                  <li class="pull-left"><a href="${ctx.host}/fitness-groups/${fitnessGroup.id}/special-courseware-templates">上课课件</a></li>
                </c:if>
            </ul>
          </div>
          
          <div class="clearfix">
          
          <div class="row" >
          
            <div class="col-xs-2 template-submenu">
              <ul class="nav nav-pills nav-stacked template-list">
                <c:forEach var="batch" items="${persist.batchCoursewareTemplate(fitnessGroup.id, type)}">
                  <li class="submenu text-center ${weeks == batch.sorting ? 'active' : ''}"><a href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${batch.sorting}?type=${type}" >${batch.name}</a></li>
                </c:forEach>
              </ul>
            </div>
            
            <div class="col-xs-7">
            
              <div class="schedule-action-layout" style="position: relative;">
                <c:forEach var="daily" items="${persist.dailyCoursewareTemplate(fitnessGroup.id,weeks, type)}">
                  <div class="action-module">
                    <label class="text-right">${daily.name}:</label>
                    <c:set var="coursewareTemplates" value="${persist.coursewareTemplate(daily.id)}"/>
                    <c:choose>
                      <c:when test="${empty daily.type or (not daily.type.rest and empty coursewareTemplates)}">
                        <div class="compile-action text-center">
                          <c:if test="${currentPrincipal.coursewareManager or currentPrincipal.root}">
                            <a href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${weeks}/daily-courseware-templates/${daily.id}/courseware-templates/create?coursewareType=weekly" class="btn btn-default btn-shadow-default" data-toggle="modal" data-target="#create">添加动作</a>
                            <a href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${weeks}/daily-courseware-templates/${daily.id}/rest" class="btn btn-rest btn-success btn-shadow-default" data-toggle="modal" data-target="#rest">设为休息日</a>
                          </c:if>
                        </div>
                      </c:when>
                      <c:when test="${daily.type.rest and empty coursewareTemplates}">
                        <div class="compile-action">
                          <p class="rest text-center">今日休息
                            <c:if test="${currentPrincipal.coursewareManager or currentPrincipal.root}">
                              <a href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${weeks}/daily-courseware-templates/${daily.id}/courseware-templates/create?coursewareType=weekly" class="" data-toggle="modal" data-target="#create">重新添加动作</a>
                            </c:if>
                          </p>
                        </div>
                      </c:when>
                      <c:otherwise>
                        <div class="compile-action clearfix">
                          <c:forEach var="type" items="${enums['coursewareMovementType']}">
                            <div class="row" style="min-height:20px;">
                              <label class="text-left">${type.description}：</label>
                              <div class="action-item">
                                <c:forEach var="courseware" items="${coursewareTemplates[type.alias]}" varStatus="status">
                                  <div class="action-layout">
                                    <c:if test="${currentPrincipal.coursewareManager or currentPrincipal.root}">
                                      <a href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${weeks}/daily-courseware-templates/${daily.id}/courseware-templates/${courseware.id}/edit" class="add-action" data-toggle="modal" data-target="#edit">
                                    </c:if>
                                      <div class="action-cover">
                                        <img src="${cloud.prod}/${courseware.movement.cover}-0.6" alt="">
                                        <p>${courseware.movement.name}</p>
                                      </div>
                                      <p>
                                        <c:if test="${courseware.groupAmount != 0}">${courseware.groupAmount}组&nbsp;&nbsp;</c:if>
                                        <c:if test="${courseware.movementNumber != 0}">每组${courseware.movementNumber}次&nbsp;&nbsp;</c:if>
                                        <c:if test="${not empty courseware.maxWeight and !fitnessGroup.type.online}">最大重量：${courseware.maxWeight}KG&nbsp;&nbsp;</c:if>
                                        <c:if test="${not empty courseware.time}">
                                          <c:choose>
                                            <c:when test="${fitnessGroup.type.online}">每组${courseware.time}分钟</c:when>
                                            <c:otherwise>计时${courseware.time}秒</c:otherwise>
                                          </c:choose>
                                        </c:if>
                                      </p>
                                    <c:if test="${currentPrincipal.coursewareManager or currentPrincipal.root}">
                                      </a>
                                      <a href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${weeks}/daily-courseware-templates/${daily.id}/courseware-templates/${courseware.id}/delete" class="close-module" data-toggle="modal" data-target="#delete"></a>
                                    </c:if>
                                    <div class="clearfix">
                                      <c:if test="${status.index ne 0}">
                                        <a href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${weeks}/daily-courseware-templates/${daily.id}/courseware-templates/${courseware.id}/rise" class="btn btn-success pull-left" style="display: inline-block; margin: 0; padding: 0 5px; font-size: 12px;"><span class="glyphicon glyphicon-menu-left"></span>向前</a>
                                      </c:if>
                                      <c:if test="${status.index + 1 ne fn:length(coursewareTemplates[type.alias])}">
                                        <a href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${weeks}/daily-courseware-templates/${daily.id}/courseware-templates/${courseware.id}/drop" class="btn btn-success pull-right" style="display: inline-block; margin: 0; padding: 0 5px; font-size: 12px;">向后<span class="glyphicon glyphicon-menu-right"></span></a>
                                      </c:if>
                                    </div>
                                  </div>
                                </c:forEach>
                                <c:if test="${currentPrincipal.coursewareManager or currentPrincipal.root}">
                                  <div class="action-layout">
                                    <a href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${weeks}/daily-courseware-templates/${daily.id}/courseware-templates/create?type=${type.alias}&coursewareType=weekly" class="add-module" data-toggle="modal" data-target="#create">
                                      <div class="action-add">
                                        <img src="${ctx.resource}/images/add.png" alt="">
                                      </div>
                                    </a>
                                  </div>
                                </c:if>
                              </div>
                            </div>
                          </c:forEach>
                          <c:if test="${currentPrincipal.coursewareManager or currentPrincipal.root}">
                            <div class="compile-action text-center">
                              <a href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${weeks}/daily-courseware-templates/${daily.id}/rest" class="btn btn-rest btn-success btn-shadow-default" data-toggle="modal" data-target="#rest">设为休息日</a>
                            </div>
                          </c:if>
                        </div>
                      </c:otherwise>
                    </c:choose>
                  </div>
                </c:forEach>
              </div>
              
            </div>
            
            <c:if test="${type == 'weekly'}">
              <div class="col-xs-3">
               <div class="diet-layout" style="margin-left:25px;">
                 <div class="row">
                   <label>饮食计划:</label>
                 </div>
                 <div class="row" style="margin-right:10px;">
                   <p>早餐：&nbsp;&nbsp;${batchCoursewareTemplate.breakfast.name}
                     <c:if test="${currentPrincipal.coursewareManager or currentPrincipal.root}">
                       <a class="pull-right" href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${batchCoursewareTemplate.id}/diet?dietType=breakfast" data-toggle="modal" data-target="#diet-edit">${not empty batchCoursewareTemplate.breakfast ? '修改' : '添加'}</a>
                     </c:if>
                   </p>
                   <c:if test="${not empty batchCoursewareTemplate.breakfast}">
                     <p>描述：&nbsp;&nbsp;${batchCoursewareTemplate.breakfast.description}</p>
                   </c:if>
                 </div>
                 <div class="row" style="margin-right:10px;">
                   <p>午餐：&nbsp;&nbsp;${batchCoursewareTemplate.lunch.name}
                     <c:if test="${currentPrincipal.coursewareManager or currentPrincipal.root}">
                       <a class="pull-right" href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${batchCoursewareTemplate.id}/diet?dietType=lunch" data-toggle="modal" data-target="#diet-edit">${not empty batchCoursewareTemplate.lunch ? '修改' : '添加'}</a>
                     </c:if>
                   </p>
                   <c:if test="${not empty batchCoursewareTemplate.lunch}">
                     <p>描述：&nbsp;&nbsp;${batchCoursewareTemplate.lunch.description}</p>
                   </c:if>
                 </div>
                 <div class="row" style="margin-right:10px;">
                   <p>晚餐：&nbsp;&nbsp;${batchCoursewareTemplate.dinner.name}
                     <c:if test="${currentPrincipal.coursewareManager or currentPrincipal.root}">
                       <a class="pull-right" href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${batchCoursewareTemplate.id}/diet?dietType=dinner" data-toggle="modal" data-target="#diet-edit">${not empty batchCoursewareTemplate.dinner ? '修改' : '添加'}</a>
                     </c:if>
                   </p>
                   <c:if test="${not empty batchCoursewareTemplate.dinner}">
                     <p>描述：&nbsp;&nbsp;${batchCoursewareTemplate.dinner.description}</p>
                   </c:if>
                 </div>
                 <c:if test="${not empty batchCoursewareTemplate.breakfast}">
                   <div class="row" style="margin-right:10px;">
                     <p>早餐加餐：&nbsp;&nbsp;${not empty batchCoursewareTemplate.breakfast.snacks ? persist.dietaryProgramTemplate(batchCoursewareTemplate.breakfast.snacks).name : ''}
                       <c:if test="${currentPrincipal.coursewareManager or currentPrincipal.root}">
                         <a class="pull-right" href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${batchCoursewareTemplate.id}/dietary-templates/${batchCoursewareTemplate.breakfast.id}/snacks" data-toggle="modal" data-target="#diet-edit">${not empty batchCoursewareTemplate.breakfast.snacks and not empty persist.dietaryProgramTemplate(batchCoursewareTemplate.breakfast.snacks) ? '修改' : '添加'}</a>
                       </c:if>
                     </p>
                     <c:if test="${not empty batchCoursewareTemplate.breakfast.snacks and not empty persist.dietaryProgramTemplate(batchCoursewareTemplate.breakfast.snacks)}">
                       <p>描述：&nbsp;&nbsp;${persist.dietaryProgramTemplate(batchCoursewareTemplate.breakfast.snacks).description}</p>
                     </c:if>
                   </div>
                 </c:if>
                 <c:if test="${not empty batchCoursewareTemplate.lunch}">
                   <div class="row" style="margin-right:10px;">
                     <p>中餐加餐：&nbsp;&nbsp;${not empty batchCoursewareTemplate.lunch.snacks ? persist.dietaryProgramTemplate(batchCoursewareTemplate.lunch.snacks).name : ''}
                       <c:if test="${currentPrincipal.coursewareManager or currentPrincipal.root}">
                         <a class="pull-right" href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${batchCoursewareTemplate.id}/dietary-templates/${batchCoursewareTemplate.lunch.id}/snacks" data-toggle="modal" data-target="#diet-edit">${not empty batchCoursewareTemplate.lunch.snacks and not empty persist.dietaryProgramTemplate(batchCoursewareTemplate.lunch.snacks) ? '修改' : '添加'}</a>
                       </c:if>
                     </p>
                     <c:if test="${not empty batchCoursewareTemplate.lunch.snacks and not empty persist.dietaryProgramTemplate(batchCoursewareTemplate.lunch.snacks)}">
                       <p>描述：&nbsp;&nbsp;${persist.dietaryProgramTemplate(batchCoursewareTemplate.lunch.snacks).description}</p>
                     </c:if>
                   </div>
                 </c:if>
                 <c:if test="${not empty batchCoursewareTemplate.dinner}">
                   <div class="row" style="margin-right:10px;">
                     <p>晚餐加餐：&nbsp;&nbsp;${not empty batchCoursewareTemplate.dinner.snacks ? persist.dietaryProgramTemplate(batchCoursewareTemplate.dinner.snacks).name : ''}
                       <c:if test="${currentPrincipal.coursewareManager or currentPrincipal.root}">
                         <a class="pull-right" href="${ctx.host}/fitness-groups/${fitnessGroup.id}/batch-courseware-templates/${batchCoursewareTemplate.id}/dietary-templates/${batchCoursewareTemplate.dinner.id}/snacks" data-toggle="modal" data-target="#diet-edit">${not empty batchCoursewareTemplate.dinner.snacks and not empty persist.dietaryProgramTemplate(batchCoursewareTemplate.dinner.snacks) ? '修改' : '添加'}</a>
                       </c:if>
                     </p>
                     <c:if test="${not empty batchCoursewareTemplate.dinner.snacks and not empty persist.dietaryProgramTemplate(batchCoursewareTemplate.dinner.snacks)}">
                       <p>描述：&nbsp;&nbsp;${persist.dietaryProgramTemplate(batchCoursewareTemplate.dinner.snacks).description}</p>
                     </c:if>
                   </div>
                 </c:if>
                </div>
              </div>
            </c:if>
          </div>
          </div>
          
        </div>
          
        </div>

      </div>

    </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/courseware/batch-courseware-template.js">
    <script type="text/javascript">
      require(['page/courseware/batch-courseware-template'], function(page) {
        page.init({
          'batchId': '${batchCoursewareTemplate.id}',
          'fitnessGroupId': '${fitnessGroupId}',
          'day': '${day}'
        })
      })
    </script>
  </d:resource>
  
</body>

</html>
